clear all;
close all;
clc;

L = 100e-6;
C = 33e-12;
R = 120;

LC = L*C;
RC = R*C;

a = [LC RC 1];
b = [1];

figure;
freqs(b,a);

Fs = 1000; Fmax = 1e6; f = 0:Fs:Fmax;
H = freqs(b, a, 2*pi*f);

figure(2);
subplot(2,1,1);
plot(f, 20*log10(abs(H)));

subplot(2,1,2);
plot(f/1e6, rad2deg(unwrap(angle(H))));

figure;
sys = tf(b,a);
impulse(sys);

Fs = 1e6*2*pi;
[bz, az] = bilinear(b, a, Fs);
[Hz, wz] = freqz(bz, az);
figure;
plot(f, abs(H), Fs*wz/2/pi , abs(Hz))

Td = 1 / Fs;
Tmod = 1000*Td;
t = 0:Td:Tmod;
stdn = 13;
n = stdn * rand(1, length(t));

figure

plot(t,n);

y = filter(bz, az, n);
plot(t, [n; y]);

nf = fft(n);
yf = fft(y);
f = 0:1/Tmod:(1/Td);
figure;
plot(f, abs(nf), f, abs(yf));